<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      //返回数组元素索引号的方法 indexOf(数组元素) 从前往后查找
      //只返回第一个满足条件的索引号
      //如果在数组里面找不到元素返回-1
      var arr = ["red", "green", "blue", "pink", "blue"];
      console.log(arr.indexOf("blue"));
      console.log(arr.indexOf("yellow"));

      //lastIndexOf 从后往前查找
      console.log(arr.lastIndexOf("blue"));
      console.log(arr.lastIndexOf("yellow"));
    </script>
  </head>
  <body></body>
</html>
